Ext.define('js.foundation.FoundationJgstShowBg', {
    extend: 'Ext.panel.Panel',
    id: 'FoundationJgstShowBg',
    requires: ['js.Util', 'js.ctrl.Common',],
    controller: 'Common',
    autoScroll : true,
    margin:'0 0 30 0',
    config: {
        layout: {
            type: 'vbox',
            align: 'stretch'
        },
    },
    bodyStyle:{
        background:'#fff'
    },
    initComponent: function () {
        let titleA  = {
            xtype: 'panel',
            html:'<img src="../../img/flagB.png" style="width:32px;height:32px;"><span style="margin-left: 10px;position: relative;top: 5px;color:#000;font-size:26px;">基础</span>'
        };
        let  titletB = {
            xtype: 'panel',
            html:'<img src="../../img/flagB.png" style="width:32px;height:32px;"><span style="margin-left: 10px;position: relative;top: 5px;color:#000;font-size:26px;">主体</span>'
        };
        let  titletC = {
            xtype: 'panel',
            html:'<img src="../../img/flagB.png" style="width:32px;height:32px;"><span style="margin-left: 10px;position: relative;top: 5px;color:#000;font-size:26px;">其他</span>'
        };
        let titleone={
            xtype: 'panel',
            margin: '50 30 30 30',
            bodyStyle: "background-color:#FFF;",
            items:[titleA,{
                xtype : "button",
                height:'40',
                cls:'buttonAAAA',
                idsAAA:'FoundationAShowPage',
                progress_type:this.jcstatus,
                engineering_id:this.engineering_id,
                handler: this.RanCheckOfQuaLehaviorAdd,
                width: '161',
                text:'添加'
            }]
        }
        let listone = Ext.create('js.foundation.FoundationAShowPage',{

            storeAll: this.storeAll,
            PageName:this.PageName,
            status:this.jcstatus,
            Zstsatus:this.statusAA,
            engineering_id:this.engineering_id
        });

        let titletwo={
            xtype: 'panel',
            margin: '50 30 30 30',
            bodyStyle: "background-color:#FFF;",
            items:[titletB,{
                xtype : "button",
                height:'40',
                cls:'buttonAAAA',
                width: '161',
                idsAAA:'FoundationAYShowPage',
                engineering_id:this.engineering_id,
                progress_type:this.ztstatus,
                handler: this.RanCheckOfQuaLehaviorAdd,
                text:'添加'
            }]
        };
        let listtwo = Ext.create('js.foundation.FoundationAYShowPage',{
            storeAll: this.storeAll,
            PageName:this.PageName,
            status:this.ztstatus,
            Zstsatus:this.statusAA,
            engineering_id:this.engineering_id
        });

        let titleC={
            xtype: 'panel',
            margin: '50 30 30 30',
            bodyStyle: "background-color:#FFF;",
            items:[titletC,{
                xtype : "button",
                height:'40',
                cls:'buttonAAAA',
                width: '161',
                idsAAA:'FoundationAXYShowPage',
                progress_type:this.qtstatus,
                engineering_id:this.engineering_id,
                handler: this.RanCheckOfQuaLehaviorAdd,
                text:'添加'
            }]
        };
        let listC = Ext.create('js.foundation.FoundationAXYShowPage',{

            storeAll: this.storeAll,
            PageName:this.PageName,
            status:this.qtstatus,
            Zstsatus:this.statusAA,
            engineering_id:this.engineering_id
        });

        let wancheng={
            xtype : "button",
            height:'40',
            cls:'buttonAAWancheng',
            margin:'0 20 0 1130',
            handler: this.wancheng,
            //自定义为12或者15
            progress_type:this.ztstatus,
            engineering_id:this.engineering_id,
            engineering_no:this.engineering_no,
            engineering_name:this.engineering_name,
            width: '150',
            text:'完成'
        }

        this.items = [
            titleone,
            listone,
            titletwo,
            listtwo,
            titleC,
            listC,
            wancheng
        ];
        this.callParent(arguments);
    },
    RanCheckOfQuaLehaviorAdd: function (btn) {
        let params = {
            engineering_id:btn.engineering_id,
            progress_type:btn.progress_type,
        };
        let idsaaa=btn.idsAAA;
        let btnCancel = Ext.create('Ext.button.Button', {
            cls: 'btnCancel',
            text: `取消`,
            scale: 'medium',
            width:140,
            height:42,
            margin:'0 0 20 200',
            handler: function (btn) {
                btn.up('window').close();
            },
            scope: this

        });
        let btnSubmit = Ext.create('Ext.button.Button', {
            cls:'btnSubmit',
            border:false,
            text: `保存`,
            margin: '0 0 20 30',
            width:140,
            height:42,
            scale: 'medium',
            handler: function (btn) {
             /*   rectification_date*/
                let rectification_date=Ext.getCmp('rectification_date').getValue();
                let supervision_date=Ext.getCmp('supervision_date').getValue();
                /*let user_id=Ext.getCmp('user_id_bbr').getValue();*/
                let user_name_bbr=Ext.getCmp('user_name_bbr').getValue();
                let inspection_date=Ext.getCmp('inspection_date').getValue();
                let inspection_no=Ext.getCmp('inspection_no').getValue();
                let inspection_name=Ext.getCmp('inspection_name').getValue();
                let supervision_details=Ext.getCmp('supervision_details').getValue();
                let user_ids=Ext.getCmp('supervisor_id_jdr').getValue();
                if(user_name_bbr===''||inspection_date===''||inspection_no===''){
                    Ext.toast('请将信息填写完整');
                }else  if(/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test(inspection_no)==false){
                    Ext.toast('手机号码不正确');
                }else {
                    let panel =Ext.getCmp('FoundationJgstShowBg')
                    panel.mask('正在加载数据请稍后');
                    util.post('/progressRoutes', {
                        action_type: 'progressAdd',
                        rectification_date:rectification_date,
                        engineering_id: params.engineering_id,
                        progress_type: params.progress_type,
                        supervision_date: supervision_date,
                        reporter_name:user_name_bbr,
                        inspection_date: inspection_date,
                        inspection_no: inspection_no,
                        inspection_name: inspection_name,
                        supervision_details: supervision_details,
                        user_ids: user_ids,
                        inspection_result: Ext.getCmp('inspection_result').getValue().inspection_result ? Ext.getCmp('inspection_result').getValue() : Ext.getCmp('inspection_result').value,
                        rectification_notice: Ext.getCmp('rectification_notice').getValue(),
                        rectification_reply: Ext.getCmp('rectification_reply').getValue(),
                        remarks: Ext.getCmp('remarks').getValue(),

                    }).then(function (response) {
                        panel.unmask();
                        let obj = Ext.decode(response.responseText);
                        if (obj.success) {
                            Ext.toast('添加成功');
                            let me = Ext.getCmp(idsaaa);
                            me.store.reload();
                            btn.up('window').close();
                        } else {
                            Ext.toast(`保存失败,${obj.message}`);
                        }
                    });
                }
            },
            scope: this
        });
        let formPanel = Ext.create('js.foundation.foundationAddPage');
        let projectMergertitle='';
        let win = util.window(formPanel, {title:'添加节点记录'  ,width:'58%',height:'91.5%',  buttons: ['->', btnCancel, btnSubmit, '->']});
        win.show();
    },
    wancheng:function(btn){
        let progress_type=btn.progress_type;
        let engineering_id=btn.engineering_id;
        let engineering_no=btn.engineering_no;
        let engineering_name=btn.engineering_name;
        //判断progress_type=12
        if(progress_type==12){
            //查询11
            util.post('/progressRoutes', {
                action_type:'progressQuery',
                progress_type:11,
                engineering_id:engineering_id
            }).then(function (response) {
                let obj= Ext.decode(response.responseText).data;
                if(obj.length>0){
                    //查询12
                    util.post('/progressRoutes', {
                        action_type:'progressQuery',
                        progress_type:12,
                        engineering_id:engineering_id
                    }).then(function (response) {
                        let obj= Ext.decode(response.responseText).data;
                        if(obj.length>0){
                            //查询13
                            util.post('/progressRoutes', {
                                action_type:'progressQuery',
                                progress_type:13,
                                engineering_id:engineering_id
                            }).then(function (response) {
                                let obj= Ext.decode(response.responseText).data;
                                if(obj.length>0){
                                    let vim={
                                        xtype:'panel',
                                        bodyPadding: '80 0 0 120',
                                        defaultType: 'textfield',
                                        html:'<span style="font-size: 26px;font-weight: normal;letter-spacing: 1px;color: #2672d9;">您确定完成当前步骤吗？</span>',
                                        dockedItems: [{
                                            dock: 'bottom',
                                            xtype: 'toolbar',
                                            ui: 'fuck',
                                            height:100,
                                            items: [{
                                                xtype: 'button',
                                                cls:'tuichu',
                                                text: `<span style="color:#fff">取消</span>`,
                                                margin: '0 0 0 100',
                                                scale: 'medium',
                                                handler: function (btn) {
                                                    btn.up('window').close();
                                                },
                                            }, {
                                                xtype: 'button',
                                                arrow: true,
                                                cls: 'tuichuA',
                                                text: `<span style="color:#fff">确定</span>`,
                                                scale: 'medium',
                                                margin: '0 125 0 30',
                                                scope: this,
                                                handler: function(btn){
                                                    util.post('/progressRoutes', {
                                                        action_type:'progressFinish',
                                                        progress_type:progress_type,
                                                        engineering_id:engineering_id
                                                    }).then(function (response) {
                                                        let obj= Ext.decode(response.responseText);
                                                        if(obj.success){
                                                            Ext.toast('成功');
                                                            btn.up('window').close();
                                                            let newPanel=Ext.getCmp('js.information.InformationListMain');
                                                            if(newPanel){
                                                                newPanel.close();
                                                            }
                                                            util.sysPanelAdd('js.information.InformationListMain',{
                                                                engineering_id:engineering_id,
                                                                engineering_no:engineering_no,
                                                                num:1,
                                                                engineering_name:engineering_name
                                                            });
                                                        }else{
                                                            Ext.toast(`保存失败,${obj.message}`);
                                                        }
                                                    });
                                                }
                                            }]
                                        }]
                                    }
                                    let winS = util.window(vim, {title: '完成' ,height: '290', width: '500'});
                                    winS.show();
                                }else{
                                    //提示谁没有数据
                                    Ext.toast('数据没有填写完整');
                                }

                            });
                        }else{
                            //提示谁没有数据
                            Ext.toast('数据没有填写完整');
                        }

                    });
                }else{
                    //提示谁没有数据
                    Ext.toast('数据没有填写完整');
                }

            });

        }else{
            util.post('/progressRoutes', {
                action_type:'progressQuery',
                progress_type:14,
                engineering_id:engineering_id
            }).then(function (response) {
                let obj= Ext.decode(response.responseText).data;
                if(obj.length>0){
                    //查询12
                    util.post('/progressRoutes', {
                        action_type:'progressQuery',
                        progress_type:15,
                        engineering_id:engineering_id
                    }).then(function (response) {
                        let obj= Ext.decode(response.responseText).data;
                        if(obj.length>0){
                            //查询13
                            util.post('/progressRoutes', {
                                action_type:'progressQuery',
                                progress_type:16,
                                engineering_id:engineering_id
                            }).then(function (response) {
                                let obj= Ext.decode(response.responseText).data;
                                if(obj.length>0){
                                    let vim={
                                        xtype:'panel',
                                        bodyPadding: '80 0 0 120',
                                        defaultType: 'textfield',
                                        html:'<span style="font-size: 26px;font-weight: normal;letter-spacing: 1px;color: #2672d9;">您确定完成当前步骤吗？</span>',
                                        dockedItems: [{
                                            dock: 'bottom',
                                            xtype: 'toolbar',
                                            ui: 'fuck',
                                            height:100,
                                            items: [{
                                                xtype: 'button',
                                                cls:'tuichu',
                                                text: `<span style="color:#fff">取消</span>`,
                                                margin: '0 0 0 100',
                                                scale: 'medium',
                                                handler: function (btn) {
                                                    btn.up('window').close();
                                                },
                                            }, {
                                                xtype: 'button',
                                                // scale: 'user',
                                                arrow: true,
                                                cls: 'tuichuA',
                                                text: `<span style="color:#fff">确定</span>`,
                                                scale: 'medium',
                                                margin: '0 125 0 30',
                                                scope: this,
                                                handler: function(btn){
                                                    util.post('/progressRoutes', {
                                                        action_type:'progressFinish',
                                                        progress_type:progress_type,
                                                        engineering_id:engineering_id
                                                    }).then(function (response) {
                                                        let obj= Ext.decode(response.responseText);
                                                        if(obj.success){
                                                            Ext.toast('成功');
                                                            btn.up('window').close();
                                                            let newPanel=Ext.getCmp('js.information.InformationListMain');
                                                            if(newPanel){
                                                                newPanel.close();
                                                            }
                                                            util.sysPanelAdd('js.information.InformationListMain',{
                                                                engineering_id:engineering_id,
                                                                engineering_no:engineering_no,
                                                                num:1,
                                                                engineering_name:engineering_name
                                                            });
                                                        }else{
                                                            Ext.toast(`<div style="font-size:28px;">保存失败,${obj.message}</div>`);
                                                        }
                                                    });
                                                }
                                            }]
                                        }]
                                    }
                                    let winS = util.window(vim, {title: '完成' ,height: '290', width: '500'});
                                    winS.show();
                                }else{
                                    //提示谁没有数据
                                    Ext.toast('数据没有填写完整');
                                }

                            });
                        }else{
                            //提示谁没有数据
                            Ext.toast('数据没有填写完整');
                        }

                    });
                }else{
                    //提示谁没有数据
                    Ext.toast('数据没有填写完整');
                }

            });


        }
    }
});